<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>报销</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no,email=no" />
		<link rel="stylesheet" href="../css/mui.min.css">			
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/OA.css" />
		
	</head>
	<body>
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/app.js"></script>
		<script type="text/javascript" charset="utf-8">
			 //mui初始化
			mui.init();
					
		</script>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">报销</h1>
		</header>
		<div class="mui-content transparent">
			<div class="space-line"></div>
			<div class="mui-input-group" >
				<div class="mui-input-row">
					<span class='mui-navigate-right'></span>
					<label>报销金额</label>  
					<input id='reimburseMoney' type="number" class="mui-input-clear " placeholder="请输入数字(必填)">
				</div>
				<div class="mui-input-row ">
					<span class='mui-navigate-right'></span>
					<label>表笑类型</label>
					<select id='type'>
						<option>周末加班</option>
						<option>晚上加班</option>
						<option>节假日加班</option>
					</select>
				</div>
				<div class="mui-input-row ">
					
					<label>费用明细</label>
					<textarea id='msg' rows="3" cols="4"  class="mui-input-clear mui-input" placeholder="请输入费用明细描述"></textarea>
				</div>
			</div>
			
			<div class="submit"> 
				<button id="submit" type="button" class="mui-btn mui-btn-primary mui-btn-block">提交</button>
			</div>
		</div>
		
		<script>
			var type=document.getElementById('type');
			var money=document.getElementById('reimburseMoney');
			var msg=document.getElementById('msg');
			var submit=document.getElementById('submit')
			
			//获取报销类型
			mui.plusReady(function() { 
				
				var userId=plus.storage.getItem("userId")
				console.log(userId+'userID'); 
				
				mui.ajax(url+'OA/GetExamineReimburseType',{
								dataType:'json',
								type:'get',
								data:{
									userId:'549', 
									webToken:'rqlh'
									},
								timeout:10000,
								success:function(data){	
									var dataLen=data.Data.length;
									var row='';
									console.log(data.Msg);  
									if(data.Code=="000"){
										for(var i = 0; i < dataLen; i++){
											row +='<option value='+data.Data[i].TypeId+'>'+data.Data[i].TypeName+'</option>'
										}
										type.innerHTML=row;
									}else{
										plus.nativeUI.toast("网络连接失败");
									} 
								},
								error:function(xhr,type,errorThrown){
									plus.nativeUI.toast("提交失败,错误原因:"+errorThrown);
									   
								}
								   
									  
				}); 
				//提交
				submit.addEventListener("tap",function(){
					console.log(type.value+'value')
					//验证
					if(!isEmpty(money.value)){
						mui.toast('报销金额不能为空');
						return;
					}
					if(!isEmpty(type.value)){
						mui.toast('报销类别不能为空');
						return;
					}
					if(!isEmpty(msg.value)){
						mui.toast('费用明细不能为空');
						return;
					}
					
					console.log("aaa"+type.value);
					mui.ajax(url+'OA/PostExamineReimburse',{
								dataType:'json',
								type:'post',
								data:{
										userId:'549', 
										typeId: type.value,										
										money: money.value, 
										msg: msg.value,
										webToken:'rqlh'
										},
								timeout:10000,
								success:function(data){									
									if(data.Code=="000"){
										plus.nativeUI.toast("报销申请已提交");
										console.log(data.Msg)
									}else{
										plus.nativeUI.toast(data.Msg);
									}
								},
								error:function(xhr,type,errorThrown){
									plus.nativeUI.toast("提交失败,错误原因:"+errorThrown);
									   
								}
								   
									  
					}); 
				});
			})
		</script>
	</body>
</html>
